package com.fire.control.system.module.user.controller.app;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fire.control.system.module.common.controller.BaseController;
import com.fire.control.system.module.user.service.IUserService;
import com.fire.control.system.standard.BusinessInterfaceStandard;
import com.fire.control.system.support.protocol.comman.ResponseProtocol;
import com.fire.control.system.support.protocol.duty.DutyRequestProtocol;
import com.fire.control.system.support.protocol.user.UserRequestProtocol;

/**
 * @author liuxincheng
 * @ClassName: AppUserControl
 * @Description: TODO(用户控制器)
 * @date 2017年6月8日 下午4:07:11
 */
@RestController
@RequestMapping(path = "/app/userCtr")
public class AppUserControl extends BaseController implements BusinessInterfaceStandard<UserRequestProtocol, ResponseProtocol> {

	@Autowired
	private IUserService userService;

	/**
	 * @author liuxincheng
	 * @Title: getUserDetail
	 * @Description: TODO(获得个人详细信息)
	 * @param @param
	 *            requestProtocol
	 * @param @return
	 *            设定文件
	 * @return ResponseProtocol 返回类型
	 * @throws null
	 */
	@RequestMapping(path = "/getUserDetail", method = RequestMethod.POST)
	public ResponseProtocol getUserDetail(@RequestBody UserRequestProtocol requestProtocol) {
		ResponseProtocol response = userService.getUserDetail(requestProtocol,this.getUser());
		return response;
	}

	/**
	 * @author liuxincheng
	 * @Title: updateUserInfo
	 * @Description: TODO(修改个人资料)
	 * @param @param
	 *            requestProtocol
	 * @param @param
	 *            request
	 * @param @return
	 *            设定文件
	 * @return ResponseProtocol 返回类型
	 * @throws null
	 */
	@RequestMapping(path = "/updateUserInfo", method = RequestMethod.POST)
	public ResponseProtocol updateUserInfo(@RequestBody UserRequestProtocol requestProtocol) {
		ResponseProtocol response = userService.updateUserInfo(requestProtocol,this.getUser());
		return response;
	}
	
	/**
	 * @author liuxincheng
	 * @Title: validateTelphoneNumber
	 * @Description: TODO(校验电话号码)
	 * @param @param requestProtocol
	 * @param @return    设定文件
	 * @return ResponseProtocol    返回类型
	 * @throws null
	 */
	@RequestMapping(path = "/validateTelphoneNumber", method = RequestMethod.POST)
	public ResponseProtocol validateTelphoneNumber(@RequestBody UserRequestProtocol requestProtocol) {
		ResponseProtocol response = userService.validateTelphoneNumber(requestProtocol,this.getUser());
		return response;
	}
	
	/**
	 * @author liuxincheng
	 * @Title: updateUserInfo
	 * @Description: TODO(发送验证码)
	 * @param @param requestProtocol
	 * @param @return    设定文件
	 * @return ResponseProtocol    返回类型
	 * @throws null
	 */
	@RequestMapping(path = "/sendSms", method = RequestMethod.POST)
	public ResponseProtocol sendSms(@RequestBody UserRequestProtocol requestProtocol) {
		ResponseProtocol response = userService.sendSms(requestProtocol);
		return response;
	}
	
/*	*//**
	 * @author liuxincheng
	 * @Title: updateUserInfo
	 * @Description: TODO(上传用户头像)
	 * @param @param requestProtocol
	 * @param @return    设定文件
	 * @return ResponseProtocol    返回类型
	 * @throws
	 *//*
	@RequestMapping(path = "uploadUserIcon", method = RequestMethod.POST)
	public ResponseProtocol uploadUserIcon(MultipartHttpServletRequest request) {
		ResponseProtocol response = userService.uploadUserIcon(request,this.getUser());
		return response;
	}*/
	
	/**
	 * @author  liuxincheng
	 * @Title: workRecord
	 * @Description: TODO(工作记录)
	 * @param @param requestProtocol
	 * @param @return    设定文件
	 * @return ResponseProtocol    返回类型
	 * @throws null
	 */
	@RequestMapping(path="/workRecord",method=RequestMethod.POST)
	public ResponseProtocol workRecord(@RequestBody DutyRequestProtocol requestProtocol,@RequestBody Pageable p){
		requestProtocol.setTaskuuid(UUID.randomUUID().toString());
		ResponseProtocol response = userService.workRecord(requestProtocol,p,getUser());
		return response;
	}
}
